package com.hu.video.service.impl;

import com.hu.video.entity.SocialComment;
import com.hu.video.mapper.SocialCommentMapper;
import com.hu.video.service.ISocialCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;

@Service
public class SocialCommentServiceImpl implements ISocialCommentService {
    @Autowired
    private SocialCommentMapper commentMapper;

    @Override
    public boolean addComment(SocialComment comment) {
        comment.setCreatedAt(new Date());
        comment.setUpdatedAt(new Date());
        comment.setStatus(1);
        return commentMapper.insertComment(comment) > 0;
    }

    @Override
    public List<SocialComment> getCommentsByVideo(Long videoId, Long currentUserId) {
        return commentMapper.selectCommentsByVideo(videoId, currentUserId);
    }

    @Override
    public List<SocialComment> getReplies(Long parentId, Long currentUserId) {
        return commentMapper.selectReplies(parentId, currentUserId);
    }

    @Override
    public List<SocialComment> getFlatCommentListByVideoId(Long videoId, Long currentUserId) {
        return commentMapper.getFlatCommentListByVideoId(videoId, currentUserId);
    }

    @Override
    public boolean deleteComment(Long commentId) {
        return commentMapper.deleteComment(commentId) > 0;
    }
} 